﻿<UserControl x:Class="ScrumFactory.Tasks.TasksList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:props="clr-namespace:ScrumFactory.Tasks.Properties"
             
             xmlns:sys="clr-namespace:System;assembly=mscorlib"

             xmlns:SF="clr-namespace:ScrumFactory;assembly=ScrumFactory"
             xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"
             xmlns:SF_DD="clr-namespace:ScrumFactory.Windows.Helpers.DragDrop;assembly=ScrumFactory.Windows.Helpers"
             xmlns:SF_Adorners="clr-namespace:ScrumFactory.Windows.Helpers.Adorners;assembly=ScrumFactory.Windows.Helpers"             
             xmlns:SF_Comp="clr-namespace:ScrumFactory.Composition;assembly=ScrumFactory.Composition" 
             xmlns:SF_Ext="clr-namespace:ScrumFactory.Windows.Helpers.Extensions;assembly=ScrumFactory.Windows.Helpers"
             
             SF_Comp:CommandBehavior.RoutedEventName="Loaded"
             SF_Comp:CommandBehavior.TheCommandToRun="{Binding OnLoadCommand}"
             
             x:Name="thisView"
             
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.InputBindings>
        <KeyBinding Key="Enter" Command="{Binding CreateTaskCommand}"/>
        <KeyBinding Key="C" Modifiers="Control" Command="{Binding CopyTasksCommand}"/>
        <KeyBinding Key="V" Modifiers="Control" Command="{Binding PasteTasksCommand}"/>
        <KeyBinding Key="T" Modifiers="Control" Command="{Binding SelectAllTasksCommand}"/>        
    </UserControl.InputBindings>

    <UserControl.Resources>




        <Style x:Key="PostItTextBox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Margin" Value="0"/>
            <Setter Property="Padding" Value="0"/>            
            <Setter Property="TextWrapping" Value="Wrap"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background">
                        <Setter.Value>
                            <SolidColorBrush Color="White" Opacity="0.3"/>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>            
        </Style>
        
        <DataTemplate x:Key="PostItDataTemplate">

            <SF_Adorners:SurroundBorderAdorner
                x:Name="itemBorder"
                Style="{StaticResource PostItBorder}"
                 Margin="2,18,2,0" 
                Width="150" MaxWidth="200" MinHeight="130" VerticalAlignment="Top"
                BorderThickness="2" >
                <Grid IsEnabled="{Binding CanEditThisTask}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <TextBox
                        Grid.Row="0"
                        Style="{StaticResource PostItTextBox}"                        
                        Text="{Binding Task.TaskName, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Stretch"
                        SpellCheck.IsEnabled="True" MaxLength="300"                              
                        SF_Comp:CommandBehavior.RoutedEventName="LostFocus"
                        SF_Comp:CommandBehavior.TheCommandToRun="{Binding ChangeTaskNameCommand}"                        
                        SF_Ext:TextBoxExtension.IsFocused="{Binding PostItTaskNameTextBoxFocus}"
                        HorizontalAlignment="Stretch" />
                    <DockPanel Grid.Row="1" HorizontalAlignment="Stretch">
                        <TextBox
                            SF_Ext:TextBoxExtension.AutoSelectOnFocus="True"
                            SF_Ext:TextBoxExtension.NumericJumper="0.5"
                            SF_Ext:TextBoxExtension.IsFocused="{Binding PostItPlannedHoursTextBoxFocus}"
                            Text="{Binding Task.PlannedHours, StringFormat='{}{0:0.#}', UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Bottom"
                            SF_Comp:CommandBehavior.RoutedEventName="LostFocus" FontWeight="Bold"
                            SF_Comp:CommandBehavior.TheCommandToRun="{Binding ChangePlannedHoursCommand}"
                            MaxLength="4"  DockPanel.Dock="Right" TextAlignment="Right"  >
                            <TextBox.Style>
                                <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource PostItTextBox}">
                                    <Setter Property="TextBox.FontSize" Value="{StaticResource SmallFontSize}"/>
                                    <Setter Property="TextBox.MinWidth" Value="13"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Task.Status}" Value="0">
                                            <Setter Property="TextBox.FontSize" Value="{StaticResource BigFontSize}"/>
                                            <Setter Property="TextBox.MinWidth" Value="30"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBox.Style>
                        </TextBox>
                        <TextBlock Text="/" VerticalAlignment="Bottom" DockPanel.Dock="Right">
                            <TextBlock.Style>
                                <Style TargetType="{x:Type TextBlock}">                                    
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Task.Status}" Value="0">
                                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                        </TextBlock>
                        <TextBox 
                            SF_Ext:TextBoxExtension.AutoSelectOnFocus="True"
                            SF_Ext:TextBoxExtension.NumericJumper="0.5"
                            Text="{Binding Task.EffectiveHours, StringFormat='{}{0:0.#}', UpdateSourceTrigger=PropertyChanged}" MinWidth="30"
                            SF_Comp:CommandBehavior.RoutedEventName="LostFocus"
                            SF_Comp:CommandBehavior.TheCommandToRun="{Binding ChangeEffectiveHoursCommand}"
                            MaxLength="4" TextAlignment="Right" DockPanel.Dock="Right" >
                            <TextBox.Style>
                                <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource PostItTextBox}">                                    
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Task.Status}" Value="0">
                                            <Setter Property="TextBox.Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBox.Style>
                        </TextBox>
                        
                        <Image DataContext="{Binding Task.TaskType}" Style="{StaticResource TaskTypeOnPostItImage}" DockPanel.Dock="Left" HorizontalAlignment="Left"/>
                        <Image DataContext="{Binding IsCanceled}" Style="{StaticResource IsTaskCanceledImage}" DockPanel.Dock="Left" HorizontalAlignment="Left"/>
                        
                    </DockPanel>                    
                    <ComboBox
                        Grid.Row="2"                                                         
                        SF_Comp:CommandBehavior.RoutedEventName="SelectionChanged"
                        SF_Comp:CommandBehavior.TheCommandToRun="{Binding ChangeTaskAssigneeCommand}"
                        IsEnabled="{Binding CanChangeAssignee}"                        
                        Style="{StaticResource TaskAssigneeComboBox}"
                        SelectedValuePath="MemberUId" SelectedValue="{Binding TaskAssigneeUId}"
                        ItemsSource="{Binding ElementName=thisView, Path=Model.ProjectMembers}"/>                        
                </Grid>
                
                <SF_Adorners:SurroundBorderAdorner.LeftControl>
                    
                        <Button
                        DataContext="{Binding ElementName=itemBorder, Path=DataContext}"
                        Margin="0,0,-10,0"
                        Style="{StaticResource MoveItemLeftButton}"
                        VerticalAlignment="Center" 
                        ToolTip="{Binding TaskMoveLeftToolTip}"
                        Command="{Binding MoveTaskLeftCommand}" />                    
                </SF_Adorners:SurroundBorderAdorner.LeftControl>
                <SF_Adorners:SurroundBorderAdorner.RightControl>
                    <Grid>
                        <Button                                                                                                 
                                VerticalAlignment="Top" Margin="-10,0,0,0" 
                                Command="{Binding DataContext.AssignTaskToMeCommand, ElementName=itemBorder}" 
                                ToolTip="{x:Static props:Resources.assign_task_to_me}">
                            <Border BorderThickness="1" BorderBrush="{StaticResource LinkBrush}">
                                <Image Source="{Binding Model.SignedMemberImageUrl, ElementName=thisView, IsAsync=True}" Width="32" Height="32"/>
                            </Border>                            
                            <Button.Style>
                                <Style TargetType="Button" BasedOn="{StaticResource CleanButton}">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding DataContext.TaskAssigneeUId, ElementName=itemBorder}" Value="{x:Null}">
                                            <Setter Property="Visibility" Value="Visible"/>
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding Model.IsSignedMemberAtProject, ElementName=thisView}" Value="False">
                                            <Setter Property="Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Button.Style>
                        </Button>
                        <Button VerticalAlignment="Center"
                            DataContext="{Binding ElementName=itemBorder, Path=DataContext}"
                            Margin="-10,0,0,0"
                            Style="{StaticResource MoveItemRightButton}"
                        
                            ToolTip="{Binding TaskMoveRightToolTip}"
                            Command="{Binding MoveTaskRightCommand}" />

                    </Grid>



                </SF_Adorners:SurroundBorderAdorner.RightControl>
                <SF_Adorners:SurroundBorderAdorner.BottomControl>
                    <DockPanel Background="Transparent">
                        <TextBlock DockPanel.Dock="Left" Margin="0,0,0,0" >
                            <Hyperlink 
                                Command="{Binding Model.ShowDetailWindowCommand, ElementName=thisView}"
                                CommandParameter="{Binding ElementName=itemBorder, Path=DataContext}">
                                <TextBlock Text="{x:Static props:Resources.Details}" FontSize="{StaticResource SmallFontSize}"/>
                            </Hyperlink>
                        </TextBlock>
                       
                        <Button 
                                DataContext="{Binding ElementName=itemBorder, Path=DataContext}"
                                DockPanel.Dock="Left" Margin="8,0,0,0"
                                Style="{StaticResource CleanButton}"
                                Command="{Binding CopyTaskTrackIdCommand}" 
                                ToolTip="{x:Static props:Resources.copy_track_info_to_clipboard}">
                            <Image Source="/Images/Toolbar/tag.png" Width="16" Height="16"/>
                        </Button>


                        <Button 
                                DataContext="{Binding ElementName=itemBorder, Path=DataContext}"
                                DockPanel.Dock="Left" Margin="8,0,0,0"
                                Style="{StaticResource CleanButton}"
                                Command="{Binding ShowRepositoryLogCommand}" 
                                ToolTip="{x:Static props:Resources.Change_log}">
                            <Image Source="/Images/Toolbar/tail.png" Width="16" Height="16"/>
                        </Button>



                        <Button
                            DockPanel.Dock="Right"                            
                            DataContext="{Binding ElementName=itemBorder, Path=DataContext}"
                            Style="{StaticResource RemoveActionButton}" Margin="0,-15,-8,0"
                            HorizontalAlignment="Right"
                            Command="{Binding CancelTaskCommand}"
                            ToolTip="{x:Static props:Resources.Cancel_task}"/>
                    </DockPanel>                    
                </SF_Adorners:SurroundBorderAdorner.BottomControl>
                                
            </SF_Adorners:SurroundBorderAdorner> 
        </DataTemplate>

        <Style x:Key="ClockButton" TargetType="Button" BasedOn="{StaticResource CleanButton}">
            <Setter Property="ToolTip" Value="{x:Static props:Resources.startClock_tooltip}"/>
            <Setter Property="Content">
                <Setter.Value>
                    <Border Style="{StaticResource MouseOverBorder}">
                        <Border CornerRadius="4" BorderThickness="1" Padding="3">
                            <TextBlock Text="{Binding ClockTime}" FontSize="{StaticResource ReallyBigFontSize}"/>
                            <Border.Style>
                                <Style>
                                    <Setter Property="Border.BorderBrush" Value="Transparent"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding IsClockTimeOver}" Value="True">
                                            <Setter Property="Border.Background" Value="{StaticResource AlertBackgroundBrush}"/>
                                            <Setter Property="Border.BorderBrush" Value="{StaticResource AlertBrush}"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Border.Style>
                        </Border>
                        
                    </Border>                    
                </Setter.Value>
            </Setter>
            
        </Style>

    </UserControl.Resources>

    <SF_Helpers:PanelLayout Title="{Binding PanelName}" >

        <!-- TOOLBAR -->
        <SF_Helpers:PanelLayout.Toolbar>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                
                <ToolBar Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch">
                    
                            
                                <MenuItem
                                    IsEnabled="{Binding IsSignedMemberAtProject}"
                                Header="{x:Static props:Resources.New_task}" Focusable="False">
                                <MenuItem.Icon>
                                    <Image Source="/Images/ToolBar/Add.png" Width="32" Height="32" Stretch="Uniform"/>
                                </MenuItem.Icon>
                
                                    <MenuItem.Style>
                                        <Style BasedOn="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}" TargetType="MenuItem">
                                            <Style.Triggers>
                                                <Trigger Property="MenuItem.IsPressed" Value="True">
                                                    <Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=addTextBox}"/>
                                                </Trigger>
                                            </Style.Triggers>
                                        </Style>
                                    </MenuItem.Style>
                                </MenuItem>

                    <MenuItem IsCheckable="True" x:Name="selectionButton" FocusManager.IsFocusScope="False" Focusable="False"
                              Header="{x:Static props:Resources.Selection}" ToolTip="{x:Static props:Resources.Selection_tooltip}">
                        <MenuItem.Style>
                            <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource Toolbar_MenuItemStyle}">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ListMode}" Value="0">
                                        <Setter Property="Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </MenuItem.Style>
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/mouse_cursor.png" Width="32" Height="32" Stretch="Uniform"/>
                        </MenuItem.Icon>
                    </MenuItem>


                    <MenuItem Grid.Column="0" Header="{x:Static props:Resources.Join}" Command="{Binding ShowJoinDialogCommand}"
                              Style="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/joinProject.png" Width="32" Height="32" Stretch="Uniform"/>
                        </MenuItem.Icon>
                    </MenuItem>

                    <TextBlock                        
                        HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap"
                        MaxWidth="120"
                        Foreground="{StaticResource LabelBrush}"
                        FontFamily="{StaticResource WideFont}"
                        FontSize="{StaticResource ReallyBigFontSize}"
                        Text="{Binding CurrentSprintLabel}"/>
                    
                   

                </ToolBar>
                
                <ToolBar Grid.Column="1" Grid.Row="0">
                    <Menu>
                        <MenuItem Command="{Binding ChangeListModeCommand}">
                            <MenuItem.Style>
                                <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource Toolbar_MenuItemStyle}">
                                    <Setter Property="Header" Value="{x:Static props:Resources.List}"/>
                                    <Setter Property="Icon">
                                        <Setter.Value>
                                            <Image Source="/Images/ToolBar/listView.png" Width="32" Height="32" Stretch="Uniform"/>
                                        </Setter.Value>
                                    </Setter>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ListMode}" Value="1">
                                            <Setter Property="Header" Value="{x:Static props:Resources.Post_it}"/>
                                            <Setter Property="Icon">
                                                <Setter.Value>
                                                    <Image Source="/Images/ToolBar/PostItView.png" Width="32" Height="32" Stretch="Uniform"/>
                                                </Setter.Value>
                                            </Setter>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </MenuItem.Style>
                        </MenuItem>
                    </Menu>
                    <TextBox 
                    ToolTip="{x:Static props:Resources.Search}"                   
                    MaxWidth="250" MinWidth="200"
                    Text="{Binding SearchFilterText, UpdateSourceTrigger=PropertyChanged}"
                    Style="{StaticResource SearchTextBox}"
                    HorizontalAlignment="Center" VerticalAlignment="Center"/>

                    <MenuItem IsCheckable="True" IsChecked="{Binding ReplanItemWhenChanged}" IsEnabled="{Binding CanReplanItemWhenChanged}"
                              Header="{x:Static props:Resources.Replan_item}" ToolTip="{x:Static props:Resources.Replan_item_tooltip}"
                              Style="{StaticResource Toolbar_MenuItemStyleHideWhenDisabled}">
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/planning.png" Width="32" Height="32" Stretch="Uniform"/>
                        </MenuItem.Icon>
                    </MenuItem>

                    <Button Style="{StaticResource ClockButton}" Margin="5,0,5,0" Command="{Binding StartStopClockCommand}" />
                    
                  




                </ToolBar>

                <DockPanel x:Name="newItemPanel"
                            Grid.ColumnSpan="2" Grid.Row="1"
                            Style="{StaticResource NewItemPanelAutoClose}">
                    <TextBlock Style="{StaticResource LabelTextBlock}" Text="{x:Static props:Resources.New_task}" DockPanel.Dock="Left"/>
                    <ComboBox
                        SelectedValue="{Binding NewTaskType, Converter={StaticResource EnumToShortConverter}, ConverterParameter={x:Type SF:TaskTypes}}"                        
                        Width="200" DockPanel.Dock="Left" 
                        ItemsSource="{Binding Source={StaticResource TaskTypeList}}">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Image Style="{StaticResource TaskTypeImage}" Margin="0,0,8,0"/>
                                    <TextBlock Text="{Binding ., Converter={StaticResource LocalizeConverter}}"/>
                                </StackPanel>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                   
                    <TextBox      
                            x:Name="addTextBox"  DockPanel.Dock="Left" 
                            ToolTip="{x:Static props:Resources.New_task_name}" 
                            Text="{Binding NewTaskName, UpdateSourceTrigger=PropertyChanged}"                                                         
                            HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
                    

                </DockPanel>
            </Grid>
        </SF_Helpers:PanelLayout.Toolbar>

        <!-- CONTENT -->
        <SF_Helpers:PanelLayout.Content>
            <Grid x:Name="grid">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <DockPanel Grid.Column="0" Margin="0,0,10,0" >

                    <CheckBox Content="{x:Static props:Resources.show_all_items}" IsChecked="{Binding ShowAllItems}" DockPanel.Dock="Top"/>
                    


                    <ListBox                                            
                        SF_Ext:ListSelectionBehavior.ClickSelection="True"                
                        SelectedItem="{Binding SelectedBacklogItem}"
                        DockPanel.Dock="Bottom"
                        ItemsSource="{Binding GroupedBacklogItems}"
                        ItemContainerStyle="{StaticResource FixesListBoxItem}"
                        SF_DD:DragDropHelper.OnDropCommand="{Binding ChangeTaskItemCommand}"
                        SF_DD:DragDropHelper.IsDragSource="False"
                        SF_DD:DragDropHelper.PositionDrop="False"
                        SF_DD:DragDropHelper.IsDropTarget="True"               
                        SF_DD:DragDropHelper.ShowInsertAdorner="False">
                        <ListBox.GroupStyle>
                            <GroupStyle>                                
                                <GroupStyle.HeaderTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Name, StringFormat='{}Sprint {0}'}" Margin="0,10,0,5" >
                                            <TextBlock.Style>
                                                <Style TargetType="TextBlock" BasedOn="{StaticResource ItemTitleTextBlock}">
                                                    <Style.Triggers>
                                                        <Trigger Property="Text" Value="Sprint ">
                                                            <!--<Setter Property="TextBlock.Text" Value="{x:Static props:Resources.not_planned}"/>-->
                                                            <Setter Property="TextBlock.Visibility" Value="Hidden"/>
                                                        </Trigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </TextBlock.Style>
                                        </TextBlock>
                                    </DataTemplate>
                                </GroupStyle.HeaderTemplate>
                            </GroupStyle>
                        </ListBox.GroupStyle>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" Margin="0,3,0,3">
                                    <TextBlock Text="{Binding BacklogItemNumber}" FontSize="{StaticResource SmallFontSize}" Width="20" TextAlignment="Right" />
                                    <Image Style="{StaticResource BacklogItemStatusImage}" DataContext="{Binding Status}" Width="30" />
                                    <TextBlock Text="{Binding Name}" FontSize="{StaticResource NormalFontSize}" TextWrapping="Wrap" Width="150" HorizontalAlignment="Left"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    
                    
                </DockPanel>


                <Border Background="White" Grid.Column="1" CornerRadius="5">
                    <ListBox  
                    x:Name="postItList"
                    
                    ItemsSource="{Binding FilteredTasksPostIt}"            
                    
                    ItemTemplate="{StaticResource PostItDataTemplate}"  
                    
                    ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                    HorizontalAlignment="Stretch" VerticalAlignment="Stretch"                    
                    
                    SF_Comp:CommandBehavior.RoutedEventName="MouseRightButtonDown"
                    SF_Comp:CommandBehavior.TheCommandToRun="{Binding CreateEmptyTaskCommand}"
                    
                                        
                    SF_DD:DragDropHelper.OnDropCommand="{Binding MoveTaskCommand}"
                    SF_DD:DragDropHelper.IsDragSource="True"
                    SF_DD:DragDropHelper.IsDropTarget="True"               
                    SF_DD:DragDropHelper.ShowInsertAdorner="False"
                    SF_DD:DragDropHelper.DragDropTemplate="{StaticResource PostItDataTemplate}">
                

                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  />
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                        <ListBox.GroupStyle>
                            <GroupStyle HidesIfEmpty="False">
                                <GroupStyle.Panel>
                                    <ItemsPanelTemplate>
                                        <UniformGrid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Columns="3" Rows="1"            
                                         ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
                                    </ItemsPanelTemplate>
                                </GroupStyle.Panel>
                                <GroupStyle.ContainerStyle>
                                    <Style TargetType="{x:Type GroupItem}">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="{x:Type GroupItem}">
                                                    <Grid Background="White">
                                                        <Image DataContext="{Binding Name}" Style="{StaticResource WhiteBoardTitleImage}" Margin="0,3,0,0"/>
                                                        <ItemsPresenter Margin="0,30,0,0" Tag="{Binding Name}" />
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </GroupStyle.ContainerStyle>
                            </GroupStyle>
                        </ListBox.GroupStyle>
                        <ListBox.ItemContainerStyle>
                            <Style BasedOn="{StaticResource NoHoverListBoxItem}" TargetType="{x:Type ListBoxItem}">                            
                                <Setter Property="SF_DD:DragDropHelper.IsDragAllowed" Value="{Binding CanEditThisTask}"/>
                            </Style>
                        </ListBox.ItemContainerStyle>                        
                    </ListBox>
                    <Border.Style>
                        <Style>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ListMode}" Value="1">
                                    <Setter Property="Border.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Border.Style>
                </Border>
               

                <ListView 
                    x:Name="normalList"
                    Grid.Column="1"            
                    Margin="0,5,0,0"
                
                    
                    IsTabStop="False" Focusable="False"
                    SF_Helpers:ListViewColumnsExtension.Stretch="True"
                
                    SF_Helpers:ItemActivation.ActivationMode="Both"            
                    SF_Helpers:ItemActivation.TheCommandToRun="{Binding ShowDetailWindowCommand}"                                    
                                                     
                ItemsSource="{Binding FilteredTasksList}"            
                
                VirtualizingStackPanel.IsVirtualizing="True"
                VirtualizingStackPanel.VirtualizationMode="Recycling"
                ScrollViewer.IsDeferredScrollingEnabled="True"
                            
                ScrollViewer.VerticalScrollBarVisibility="Auto"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled"            
                VerticalAlignment="Stretch">
                    
                    <ListView.ItemsPanel>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel/>
                        </ItemsPanelTemplate>
                    </ListView.ItemsPanel>
                    <ListView.View>
                        <GridView>
                            <!--<GridViewColumn Width="0" x:Name="selectionColumn">                                     
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                    
                                            <CheckBox IsChecked="{Binding IsSelected}" Content="" Width="24">
                                                <CheckBox.Style>
                                                    <Style BasedOn="{StaticResource {x:Type CheckBox}}" TargetType="CheckBox">
                                                        <Setter Property="Visibility" Value="Collapsed"/>
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding IsChecked, ElementName=selectionButton}" Value="True">
                                                                <Setter Property="Visibility" Value="Visible"/>
                                                            </DataTrigger>
                                                        </Style.Triggers>                                                                                                            
                                                </Style>
                                                </CheckBox.Style>
                                            </CheckBox>
                                    
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>-->
                            <GridViewColumn Header="{x:Static props:Resources.Done}" Width="50">                                
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid HorizontalAlignment="Stretch">
                                            <ToggleButton IsChecked="{Binding IsFinished}" IsEnabled="{Binding CanEditThisTask}" HorizontalAlignment="Left">
                                                <ToggleButton.Style>
                                                    <Style BasedOn="{StaticResource CheckToggleButton}" TargetType="{x:Type ToggleButton}">
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding IsCanceled}" Value="True">
                                                                <Setter Property="Visibility" Value="Collapsed"/>
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </ToggleButton.Style>
                                            </ToggleButton>
                                            <Image Style="{StaticResource IsTaskCanceledImage}" DataContext="{Binding IsCanceled}" Width="32" Height="32" HorizontalAlignment="Left"/>
                                        </Grid>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>

                            <GridViewColumn Header="{x:Static props:Resources.Assignee}" Width="90">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <ComboBox                
                                            SF_Comp:CommandBehavior.RoutedEventName="SelectionChanged"
                                            SF_Comp:CommandBehavior.TheCommandToRun="{Binding ChangeTaskAssigneeCommand}"
                                            IsEnabled="{Binding CanChangeAssignee}"
                                            Style="{StaticResource TaskAssigneeComboBoxWithImage}"                                                                                     
                                            SelectedValuePath="MemberUId" SelectedValue="{Binding TaskAssigneeUId}"
                                            ItemsSource="{Binding ElementName=thisView, Path=Model.ProjectMembers}"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>

                            <GridViewColumn Header="{x:Static props:Resources.Task}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>                
                                        <Grid>
                                            <TextBlock HorizontalAlignment="Right" VerticalAlignment="Top" Height="16">
                                                <Image
                                                    DataContext="{Binding Task.TaskType}" VerticalAlignment="Center"
                                                    Style="{StaticResource TaskTypeOnPostItImage}"/>
                                                <TextBlock Text="{Binding Task.TaskNumber}" Foreground="{StaticResource SubTextBrush}" FontSize="{StaticResource SmallFontSize}"  VerticalAlignment="Center"/>    
                                            </TextBlock>
                                            <TextBlock TextWrapping="Wrap" VerticalAlignment="Center" >
                                                <Hyperlink
                                                    Command="{Binding Model.ShowDetailWindowCommand, ElementName=thisView}"
                                                    CommandParameter="{Binding .}">
                                                    <Run Text="{Binding Task.TaskName}" FontSize="{StaticResource BigFontSize}"/>        
                                                </Hyperlink>
                                            </TextBlock>
                                        </Grid>
                                            
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                          
                            <GridViewColumn Header="{x:Static props:Resources.Start}" Width="90">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Task.StartDate, Converter={StaticResource ContextDateConverter}}" VerticalAlignment="Center" TextAlignment="Center"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="{x:Static props:Resources.End}" Width="90">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Task.EndDate, Converter={StaticResource ContextDateConverter}}" VerticalAlignment="Center" TextAlignment="Center"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>                            
                            <GridViewColumn Header="{x:Static props:Resources.Planned}" Width="70">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBox 
                                            SF_Ext:TextBoxExtension.AutoSelectOnFocus="True"
                                            SF_Ext:TextBoxExtension.NumericJumper="0.5"
                                            SF_Comp:CommandBehavior.RoutedEventName="LostFocus"
                                            SF_Comp:CommandBehavior.TheCommandToRun="{Binding ChangePlannedHoursCommand}" Width="50" VerticalAlignment="Center"
                                        Text="{Binding Task.PlannedHours, UpdateSourceTrigger=PropertyChanged}" MaxLength="4" Background="Transparent" TextAlignment="Right" IsEnabled="{Binding CanEditThisTask}"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="{x:Static props:Resources.Real}" Width="100">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
                                            <TextBox
                                                VerticalAlignment="Center"
                                                SF_Ext:TextBoxExtension.AutoSelectOnFocus="True"
                                                SF_Ext:TextBoxExtension.NumericJumper="0.5" Margin="0"
                                                SF_Comp:CommandBehavior.RoutedEventName="LostFocus"
                                                SF_Comp:CommandBehavior.TheCommandToRun="{Binding ChangeEffectiveHoursCommand}" 
                                                Width="50" Text="{Binding Task.EffectiveHours, UpdateSourceTrigger=PropertyChanged}" MaxLength="4" Background="Transparent" TextAlignment="Right" IsEnabled="{Binding CanEditThisTask}"/>
                                            <TextBlock 
                                                FontSize="{StaticResource SmallFontSize}" Width="30" Background="Yellow"
                                                Text="?" VerticalAlignment="Center" TextAlignment="Center" Margin="3,0,0,0">
                                                <TextBlock.Style>
                                                    <Style>
                                                        <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding TaskRole}" Value="{x:Null}">
                                                                <Setter Property="TextBlock.Visibility" Value="Visible"/>
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </TextBlock.Style>
                                            </TextBlock>
                                            <TextBlock 
                                                FontSize="{StaticResource TinyFontSize}" Width="30"
                                                Text="{Binding TaskRole.RoleShortName}" VerticalAlignment="Center" 
                                                TextWrapping="Wrap" TextAlignment="Left" Margin="3,0,0,0"/>
                                           
                                        </StackPanel>
                                        
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>                            
                        </GridView>
                    </ListView.View>
                    <ListView.Style>
                        <Style BasedOn="{StaticResource {x:Type ListView}}" TargetType="{x:Type ListView}">
                            <Setter Property="ListView.SelectionMode" Value="Single"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ListMode}" Value="0">
                                    <Setter Property="ListBox.Visibility" Value="Collapsed"/>
                                </DataTrigger>                                                                
                                <DataTrigger Binding="{Binding IsChecked, ElementName=selectionButton}" Value="True">
                                    <Setter Property="ListView.SelectionMode" Value="Multiple"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ListView.Style>                    
                </ListView>

                <Border Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,20,20,0">
                    <DockPanel>
                        <StackPanel DockPanel.Dock="Left">
                            <TextBlock 
                                Foreground="Black"
                                Text="{Binding SelectedTasksCount}" FontSize="{StaticResource ReallyBigFontSize}" 
                                HorizontalAlignment="Center" FontWeight="Bold"/>
                            <TextBlock 
                                Foreground="Black"
                                Text="{x:Static props:Resources.Tasks}" HorizontalAlignment="Center"/>
                        </StackPanel>
                        <StackPanel DockPanel.Dock="Right" Margin="20,0,0,0" VerticalAlignment="Center">
                            <TextBlock Text="{Binding SelectedTasksPlannedHours, StringFormat={x:Static props:Resources.N_planned}}"/>
                            <TextBlock Text="{Binding SelectedTasksEffectiveHours, StringFormat={x:Static props:Resources.N_spent}}"/>
                            <TextBlock Text="{x:Static props:Resources.copytasks_tooltip}" FontSize="{StaticResource SmallFontSize}" FontStyle="Italic" Foreground="{StaticResource LabelBrush}"/>
                        </StackPanel>
                        
                    </DockPanel>
                    <Border.Style>
                        <Style BasedOn="{StaticResource AlertBorder}" TargetType="Border">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding SelectedTasksCount}" Value="0">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding SelectedTasksCount}" Value="1">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Border.Style>
                </Border>

                <ContentControl  Grid.Column="1"                                                                       
                        Style="{StaticResource LoadingAnimationContent}"/>


                <TextBlock Grid.Column="1" Text="{x:Static props:Resources.Please_select_a_backlog_item}" VerticalAlignment="Center" HorizontalAlignment="Center">
                    <TextBlock.Style>
                        <Style>
                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                            <Style.Triggers>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding ListMode}" Value="1"/>
                                        <Condition Binding="{Binding SelectedBacklogItem}" Value="{x:Null}"/>
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="TextBlock.Visibility" Value="Visible"/>
                                </MultiDataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBlock.Style>
                </TextBlock>

                <StackPanel Grid.Column="1"
                            Orientation="Horizontal" HorizontalAlignment="Left" Margin="20,100,0,0" 
                            VerticalAlignment="Top" IsHitTestVisible="False">
                    <Image Source="/Images/information.png"  Width="16" Height="16" Margin="0,0,10,0"/>
                    <TextBlock Text="{x:Static props:Resources.add_task_tooltip}" TextWrapping="Wrap" Width="200"/>
                    <StackPanel.Style>
                        <Style>
                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ShowAddTaskToolTip}" Value="True">
                                    <Setter Property="TextBlock.Visibility" Value="Visible"/>
                                </DataTrigger>                                
                            </Style.Triggers>
                        </Style>
                    </StackPanel.Style>
                </StackPanel>

            </Grid>
        </SF_Helpers:PanelLayout.Content>
    </SF_Helpers:PanelLayout>

    
</UserControl>
